//
//  XMGFriTrendViewController.m
//  BuDeJie
//
//  Created by Avril on 2020/3/15.
//  Copyright © 2020 Avril. All rights reserved.
//

#import "XMGFriTrendViewController.h"
#import "UIBarButtonItem+Item.h"

@interface XMGFriTrendViewController ()
@property(nonatomic,weak) UISwitch *s;
@end

@implementation XMGFriTrendViewController

//+ (void)load{
//
//        /**
//         这样设置，点击屏幕之后switch的底图颜色不变，因为如果通过appearance设置属性，必须要在显示之前设置，比如在load方法中
//         ***/
//        UISwitch *s = [UISwitch appearance];
//        s.onTintColor = [UIColor redColor];
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
   // [self setupSwitch];
    [self setupNavBar];
 
}

-(void)setupSwitch{
    
    UISwitch *switchView = [[UISwitch alloc]init];
     
     /**
      这样设置，点击屏幕之后switch的底图颜色不变，因为如果通过appearance设置属性，必须要在显示之前设置，比如在load方法中
      ***/
     UISwitch *s = [UISwitch appearance];
     s.onTintColor = [UIColor redColor];
     
     [self.view addSubview:switchView];
     switchView.center = CGPointMake(200, 200);
     switchView.on = YES;
     _s = switchView;
    
}

-(void)setupNavBar{
    
    //设置导航条内容=》栈顶控制器的navationItem决定
    self.navigationItem.title = @"我的关注";
        //错误，导航条内容不能由导航控制器来设置,必须通过导航控制器的栈顶控制器来设置，所以导航控制器必须有根控制器
    //    self.navigationController.navigationItem.titleView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"MainTitle"]];
        
        /**
         bug:按钮点击范围扩大，不要让按钮扩大点击范围
         原因：把UIButton按钮包装成UIBarButtonItem就有问题。
         解决办法：先把UIButton加到一个view上，再把UIView加到UIBarButtonItem上。
         
         ****/

        //左边
        self.navigationItem.leftBarButtonItem =  [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"friendsRecommentIcon"] highImage:[UIImage imageNamed:@"friendsRecommentIcon-click"] target:self action:@selector(recommentClick)];
         
  
}

-(void)recommentClick{
    
    NSLog(@"点击了评论按钮");
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    //
    //_s.onTintColor = [UIColor redColor];
    
//    /**
//     这样设置，点击屏幕之后switch的底图颜色不变，因为如果通过appearance设置属性，必须要在显示之前设置，比如在load方法中
//     ***/
//    UISwitch *s = [UISwitch appearance];
//    s.onTintColor = [UIColor redColor];

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
